<?php

namespace frontend\modules\yii2\models;

use Yii;
use yii\base\Model;


class Register extends Model{
    public $username;
    public $password;
    public $password_repeat;
    public $verifyCode;

    public function rules()
    {
        return [
            [["username", "password", "password_repeat","verifyCode"], "required"],
            // 没有compareAttribute和commpareValue，因此默认和password_repeat属性进行等值比较
            ["password", "compare"],
            // 验证码校验
            //['verifyCode', 'captcha'],
        ];
    }

    public function scenarios()
    {
        $scenarios = parent::scenarios();
        // 定义灯设备场景下的属性列表
        $scenarios["login"] = ["username", "password", "password_repeat","!verifyCode"];
        return $scenarios;
    }
}